package slotMachineGUI;
/**
 * 
 * This program is a Java slot machine video game using the swing GUI.
 * 
 * The difficulty is determined by the number of images stored inside the ArrayList.
 * Credits are required to play, they can be bought with winnings.
 * 
 * If you run out of credits and have no winnings to buy more you will not be able to 
 * continue playing! www.gambleaware.co.uk
 * 
 * Date: 09/03/2012
 * @author: Michael Warner (i7904353)
 * Week 20 Assessed Task 1
 * 
 * Task: 	For this task you can create any GUI you want to.
 *
 */

import java.awt.*;
import javax.swing.*;
import javax.swing.LayoutStyle.ComponentPlacement;
import java.util.Random;
import java.util.ArrayList;
import javax.swing.border.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

import javax.swing.GroupLayout.Alignment;


public class GUI {

	private JButton btnSpin;
	private ButtonsFactory factoryTest;
	private JFrame frmFrame;
	private JLabel lblReel;
	private JLabel lblImage;
	private JLabel lblAddress;
	private JPanel pnlReels, pnlReel;
	private static int reel = 0;
	private static int count=0;
	private String destinationAddress;
	private String sourceAddress = "台灣台南市東區大學路1號";
	private int lowPrice=100,highPrice=150;
    
	private ArrayList<ImageIcon> images = new ArrayList<ImageIcon>();
	private final ButtonGroup buttonGroup = new ButtonGroup();
	private JTextField tfKeyword;
	private JTextField tfHighPrice;
	private JTextField tfLowPrice;
	private String keyWord;
	private String preKeyWord;
	private String place;
	private String prePlace;
	
	private GMap map;
	
	public GUI() {	
		createForm();
		addFields();
		addButtons();
		layoutFrame();
		layoutReels();
		layoutOther();
	}		
	
   

	/** Creates the JFrame and Panels. */
	private void createForm() {

		frmFrame = new JFrame();
		frmFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
		frmFrame.setTitle("Food Slot Machine");
		frmFrame.setResizable(false);
		frmFrame.setVisible(true);

		pnlReels = new JPanel();
		pnlReels.setBorder(BorderFactory.createEtchedBorder());

		pnlReel = new JPanel();
		pnlReel.setBackground(new Color(255, 215, 0));
		pnlReel.setBorder(new SoftBevelBorder(BevelBorder.LOWERED));

	}
	
	public String choosedStore(int reel,String filename) {
		String store="店家名稱";
		String image="店家縮圖";
		if(reel==0){
			
			return store;
		}else{
		
		FileReader FileStream;
      
		try {
			FileStream = new FileReader(filename);
			BufferedReader BufferedStream=new BufferedReader(FileStream);
			for(int i=0;i<reel;i++){
				try {
					store=BufferedStream.readLine();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String[] names = store.split(",");
		destinationAddress=names[2];
		image=names[1];
		
		lblAddress.setFont(new Font("PMingLiU", Font.PLAIN, 18));
		lblAddress.setText(destinationAddress);
		lblImage.setText("<html>"+"<img src="+image+">"+"</img></html>");
		
		return names[0]; 
		}
		
	}
	
	public int storeCount(String fileName){
	// 1.建立 File 物件
	FileReader FileStream;
	try {
		FileStream = new FileReader(fileName);
		BufferedReader BufferedStream=new BufferedReader(FileStream);
		count=0;
		try {
			while(BufferedStream.readLine()!=null){
				count++;
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	} catch (FileNotFoundException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
    
    // 2. 以 BufferedReader 來讀資料
   
     return count;
    
	}

	/** Adds labels to the form. */
	private void addFields() {

		lblReel = new JLabel();
		lblImage = new JLabel();
		lblAddress = new JLabel("Welcome to Food Slot Machine!!");
		lblAddress.setFont(new Font("French Script MT", Font.PLAIN, 24));
		lblReel.setHorizontalAlignment(SwingConstants.RIGHT);
		lblReel.setText("<html><font size=15>"+choosedStore(reel,"ShopList.txt")+"</font></html>");
		
	}
	
	/*Design pattern */
	class ButtonsFactory {
		public void getSpinButtons(JButton button) {
			button.setBackground(new Color(50, 255, 50));
			button.setText("Spin");
			button.setToolTipText("Click to spin the reels!");
			button.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
			button.setInheritsPopupMenu(true);
			button.setMaximumSize(new Dimension(200, 50));
			button.setMinimumSize(new Dimension(200, 50));
			button.addActionListener(new SpinHandler());
		    } 

	}
		
	/** Adds buttons to the form. */  /*factory*/
	private void addButtons() {

		btnSpin = new JButton();
		factoryTest = new ButtonsFactory();
		factoryTest.getSpinButtons(btnSpin);

	}

	/** Lays out the frame. */
	private void layoutFrame() {
	}

	/** Lays out the panels and reels. */
	private void layoutReels() {

		GroupLayout pnlReelsLayout = new GroupLayout(pnlReels);
		pnlReelsLayout.setHorizontalGroup(
			pnlReelsLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(pnlReelsLayout.createSequentialGroup()
					.addContainerGap()
					.addComponent(pnlReel, GroupLayout.DEFAULT_SIZE, 318, Short.MAX_VALUE)
					.addContainerGap())
		);
		pnlReelsLayout.setVerticalGroup(
			pnlReelsLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(pnlReelsLayout.createSequentialGroup()
					.addContainerGap()
					.addComponent(pnlReel, GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE)
					.addContainerGap())
		);
		pnlReels.setLayout(pnlReelsLayout);

		GroupLayout pnlReelLayout = new GroupLayout(pnlReel);
		pnlReel.setLayout(pnlReelLayout);
		pnlReelLayout.setHorizontalGroup(
				pnlReelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
				.addGroup(pnlReelLayout.createSequentialGroup()
						.addContainerGap()
						.addComponent(lblReel)
						.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
				);
		pnlReelLayout.setVerticalGroup(
				pnlReelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
				.addGroup(pnlReelLayout.createSequentialGroup()
						.addContainerGap()
						.addComponent(lblReel)
						.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
				);

	}

	/** lays out the remaining labels, check boxes, progress bars, etc. */
private void layoutOther() {
		
		map = new GMap();
		JLabel lblPlace = new JLabel("地區");
		
		JRadioButton radioButton_0 = new JRadioButton("台北");
		buttonGroup.add(radioButton_0);
		radioButton_0.setActionCommand("台北");
		
		JRadioButton radioButton_1 = new JRadioButton("新北");
		buttonGroup.add(radioButton_1);
		radioButton_1.setActionCommand("新北");
		
		JRadioButton radioButton_2 = new JRadioButton("台中");
		buttonGroup.add(radioButton_2);
		radioButton_2.setActionCommand("台中");
		
		JRadioButton radioButton_3 = new JRadioButton("台南");
		buttonGroup.add(radioButton_3);
		radioButton_3.setActionCommand("台南");
		
		JRadioButton radioButton_4 = new JRadioButton("高雄");
		buttonGroup.add(radioButton_4);
		radioButton_4.setActionCommand("高雄");
		
		JRadioButton radioButton_5 = new JRadioButton("基隆");
		buttonGroup.add(radioButton_5);
		radioButton_5.setActionCommand("基隆");
		
		JRadioButton radioButton_6 = new JRadioButton("桃園");
		buttonGroup.add(radioButton_6);
		radioButton_6.setActionCommand("桃園");
		
		JRadioButton radioButton_7 = new JRadioButton("新竹");
		buttonGroup.add(radioButton_7);
		radioButton_7.setActionCommand("新竹");
		
		JRadioButton radioButton_8 = new JRadioButton("苗栗");
		buttonGroup.add(radioButton_8);
		radioButton_8.setActionCommand("苗栗");
		
		JRadioButton radioButton_9 = new JRadioButton("彰化");
		buttonGroup.add(radioButton_9);
		radioButton_9.setActionCommand("彰化");
		
		JRadioButton radioButton_10 = new JRadioButton("南投");
		buttonGroup.add(radioButton_10);
		radioButton_10.setActionCommand("南投");
		
		JRadioButton radioButton_11 = new JRadioButton("雲林");
		buttonGroup.add(radioButton_11);
		radioButton_11.setActionCommand("雲林");
		
		JRadioButton radioButton_12 = new JRadioButton("嘉義");
		buttonGroup.add(radioButton_12);
		radioButton_12.setActionCommand("嘉義");
		
		JRadioButton radioButton_13 = new JRadioButton("屏東");
		buttonGroup.add(radioButton_13);
		radioButton_13.setActionCommand("屏東");
		
		JRadioButton radioButton_14 = new JRadioButton("宜蘭");
		buttonGroup.add(radioButton_14);
		radioButton_14.setActionCommand("宜蘭");
		
		JRadioButton radioButton_15 = new JRadioButton("花蓮");
		buttonGroup.add(radioButton_15);
		radioButton_15.setActionCommand("花蓮");
		
		JRadioButton radioButton_16 = new JRadioButton("台東");
		buttonGroup.add(radioButton_16);
		radioButton_16.setActionCommand("台東");
		
		JRadioButton radioButton_17 = new JRadioButton("澎湖");
		buttonGroup.add(radioButton_17);
		radioButton_17.setActionCommand("澎湖");
		
		JRadioButton radioButton_18 = new JRadioButton("金門");
		buttonGroup.add(radioButton_18);
		radioButton_18.setActionCommand("金門");
		
		JLabel lblKeyword = new JLabel("你想吃什麼?");
		
		tfKeyword = new JTextField();
		tfKeyword.setColumns(10);
		
		JLabel lblPrice = new JLabel("價錢定位");
		
		JLabel lbldash = new JLabel("~");
		
		tfHighPrice = new JTextField();
		tfHighPrice.setColumns(5);
		
		tfLowPrice = new JTextField();
		tfLowPrice.setColumns(5);
		
		JPanel pnlImage = new JPanel();
	
		GroupLayout layout = new GroupLayout(frmFrame.getContentPane());
		layout.setHorizontalGroup(
			layout.createParallelGroup(Alignment.LEADING)
				.addGroup(layout.createSequentialGroup()
					.addContainerGap()
					.addGroup(layout.createParallelGroup(Alignment.LEADING)
						.addComponent(btnSpin, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 342, Short.MAX_VALUE)
						.addComponent(pnlReels, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
						.addComponent(radioButton_1)
						.addComponent(radioButton_2)
						.addComponent(radioButton_5)
						.addComponent(radioButton_6)
						.addComponent(radioButton_7)
						.addComponent(radioButton_8)
						.addComponent(radioButton_9)
						.addComponent(radioButton_10)
						.addComponent(radioButton_11)
						.addComponent(radioButton_12)
						.addComponent(radioButton_13)
						.addComponent(radioButton_14)
						.addComponent(radioButton_15)
						.addComponent(radioButton_16)
						.addComponent(radioButton_17)
						.addComponent(radioButton_18)
						.addGroup(layout.createSequentialGroup()
							.addGroup(layout.createParallelGroup(Alignment.LEADING)
								.addComponent(lblPlace)
								.addComponent(radioButton_0)
								.addComponent(radioButton_3)
								.addComponent(radioButton_4))
							.addGap(61)
							.addGroup(layout.createParallelGroup(Alignment.LEADING)
								.addComponent(lblPrice)
								.addComponent(tfKeyword, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(lblKeyword)
								.addGroup(layout.createSequentialGroup()
									.addPreferredGap(ComponentPlacement.RELATED)
									.addGroup(layout.createParallelGroup(Alignment.LEADING)
										.addComponent(pnlImage, GroupLayout.PREFERRED_SIZE, 194, GroupLayout.PREFERRED_SIZE)
										.addGroup(layout.createSequentialGroup()
											.addComponent(tfLowPrice, GroupLayout.PREFERRED_SIZE, 51, GroupLayout.PREFERRED_SIZE)
											.addPreferredGap(ComponentPlacement.RELATED)
											.addComponent(lbldash)
											.addPreferredGap(ComponentPlacement.RELATED)
											.addComponent(tfHighPrice, GroupLayout.PREFERRED_SIZE, 51, GroupLayout.PREFERRED_SIZE))
										.addComponent(lblAddress))))
							.addGap(38)))
					.addGap(18)
					.addComponent(map, GroupLayout.PREFERRED_SIZE, 628, GroupLayout.PREFERRED_SIZE))
		);
		layout.setVerticalGroup(
			layout.createParallelGroup(Alignment.LEADING)
				.addGroup(layout.createSequentialGroup()
					.addContainerGap()
					.addComponent(pnlReels, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(btnSpin, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(ComponentPlacement.UNRELATED)
					.addGroup(layout.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblPlace)
						.addComponent(lblKeyword))
					.addPreferredGap(ComponentPlacement.RELATED)
					.addGroup(layout.createParallelGroup(Alignment.BASELINE)
						.addComponent(radioButton_0)
						.addComponent(tfKeyword, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(radioButton_1)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(radioButton_2)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addGroup(layout.createParallelGroup(Alignment.BASELINE)
						.addComponent(radioButton_3)
						.addComponent(lblPrice))
					.addPreferredGap(ComponentPlacement.RELATED)
					.addGroup(layout.createParallelGroup(Alignment.BASELINE)
						.addComponent(radioButton_4)
						.addComponent(lbldash)
						.addComponent(tfHighPrice, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(tfLowPrice, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(ComponentPlacement.RELATED)
					.addGroup(layout.createParallelGroup(Alignment.TRAILING)
						.addGroup(layout.createSequentialGroup()
							.addComponent(radioButton_5)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(radioButton_6)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(radioButton_7)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(radioButton_8)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(radioButton_9)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(radioButton_10)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(radioButton_11)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(radioButton_12))
						.addComponent(pnlImage, GroupLayout.PREFERRED_SIZE, 167, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(radioButton_13)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(radioButton_14)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addGroup(layout.createParallelGroup(Alignment.LEADING)
						.addGroup(layout.createSequentialGroup()
							.addComponent(radioButton_15)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(radioButton_16)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(radioButton_17)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(radioButton_18))
						.addComponent(lblAddress))
					.addContainerGap(56, Short.MAX_VALUE))
				.addComponent(map, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 650, Short.MAX_VALUE)
		);
		
		pnlImage.add(lblImage);
		map.setLayout(null);
		frmFrame.getContentPane().setLayout(layout);

		frmFrame.pack();

	}

	/** Performs action when Spin button is clicked. */
	class SpinHandler implements ActionListener {
		public void actionPerformed(ActionEvent event) {
			pnlReel.setBackground(new java.awt.Color(255, 215, 0));
			
			preKeyWord = keyWord;
			keyWord = tfKeyword.getText();
			if(keyWord == null) //如果沒有輸入搜尋條件，則預設為"小吃"
				keyWord = "小吃";
			
			prePlace = place;
			
			if(buttonGroup.getSelection() == null)
				place = "台南"; //如果沒有選擇地點，則預設為"台南"
			else
				place = buttonGroup.getSelection().getActionCommand();
			
			if(!tfLowPrice.getText().matches("[0-9]+") || !tfHighPrice.getText().matches("[0-9]+")) {
				lowPrice=0; //如果輸入價錢非預設格式或是沒有輸入，則價錢為預設值
				highPrice=2000;
			}
			else {
				lowPrice = Integer.parseInt(tfLowPrice.getText());
				highPrice = Integer.parseInt(tfHighPrice.getText());
			}
			
			//如果參數不變，則不用連上網路
			if(preKeyWord == null || prePlace == null || !preKeyWord.equals(keyWord) || !prePlace.equals(place)) {
				ShopNameAddress.ShopNameAddress("0 "+keyWord+" "+place);
				ShopNameAddress.start();
			}
			genReelNumbers();
		
			if(place.equals("台南"))
				map.setAddress(sourceAddress, destinationAddress);
			else
				map.setAddress(destinationAddress);	
		}
	}	
	
	public int priceSearch(int lowPrice,int highPrice,String filename){
		
			FileReader FileStream;
			String wholeData="價錢";
			int i=0,j=0;
			try {
				FileStream = new FileReader(filename);
				BufferedReader BufferedStream=new BufferedReader(FileStream);
				try {
					while(i<count){
						wholeData=BufferedStream.readLine();
						String[] names = wholeData.split(",");
						if(names.length != 4) {  //出現廣告 或 沒有價錢則捨棄此筆資料
							i++;
							continue;
						}
						if(Integer.valueOf(names[3])>=lowPrice && Integer.valueOf(names[3])<=highPrice) {
							j=1;
							break;
						}
						i++;
					}
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			if(j==0){
				return 0;
			}else{
				return 1;
			}
		
	}
	public int priceCheck(int reel,int lowPrice,int highPrice,String filename){
		if(reel==0){
			return 0;
		}else{
			FileReader FileStream;
			String wholeData="價錢";
			try {
				FileStream = new FileReader(filename);
				BufferedReader BufferedStream=new BufferedReader(FileStream);
				for(int i=0;i<reel;i++){
					try {
						wholeData=BufferedStream.readLine();
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
				
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			String[] names = wholeData.split(","); 
			
			if(names.length != 4) {  //出現廣告 或 沒有價錢則捨棄此筆資料
				return 0;
			}
			
			int price=Integer.valueOf(names[3]);
			
			if(price>=lowPrice && price<=highPrice){
				return 1;
			}else{
				return 0;
			}
			
		}
		
	}
	/** Generates a reel number. */
	public void genReelNumbers() {
		Random rand = new Random();
		storeCount("ShopList.txt");
		reel=0;
		if(priceSearch(lowPrice,highPrice,"ShopList.txt")==0) {
			lblReel.setText("<html><font size=15>無法找到符合條件的<center>店家資料</center></font></html>");
		}
		else {
			while(priceCheck(reel,lowPrice,highPrice,"ShopList.txt")==0)
				reel= rand.nextInt(count)+1;
			setReelIcon(reel); // Set the reel image
		}
	}

	/** Sets the reels icon based on Store name in Store list. */
	public void setReelIcon(int ico1) {
		lblReel.setText("<html><font size=15>"+choosedStore(reel,"ShopList.txt")+"</html>");
	}
//
//	/** Loads ImageIcons into the images ArrayList. 
//	 *	The difficulty is determined by the number of images present in the ArrayList:
//	 *		?	Add images here to make game more difficult. 
//	 *		?	Remove images here to make game easier. 
//	 */
//	public void loadImages() {
//		images.add(createImageIcon("images/Banana.png", "Banana"));
//		images.add(createImageIcon("images/Bar.png", "Bar"));
//		images.add(createImageIcon("images/Bell.png", "Bell"));
//		images.add(createImageIcon("images/Cherry.png", "Cherry"));
//		images.add(createImageIcon("images/Clover.png", "Clover"));
//		images.add(createImageIcon("images/Diamond.png", "Diamond"));
//		images.add(createImageIcon("images/Plum.png", "Plum"));
//		images.add(createImageIcon("images/Seven.png", "Seven"));
//		images.add(createImageIcon("images/Watermelon.png", "Watermelon"));
//	}

	/** Create a new ImageIcon, unless the URL is not found. */
	public ImageIcon createImageIcon(String path, String description) {
		java.net.URL imgURL = getClass().getResource(path);
		if (imgURL != null) {
			return new ImageIcon(imgURL, description);
		} else {
			System.err.println("Couldn't find file: " + path);
			return null;
		}
	}
	
	interface Visitable {   
		void accept(Visitor visitor);
	}
	interface Visitor {    
		void visit(Member member);    
	}
	class Customer implements Visitable {    
		void serveCustomer() {        
			System.out.println("使用者服務");   
	    }    
		void charge() {        
			System.out.println("儲值");    
		}    
		public void accept(Visitor visitor) {        
			// nothing to do    
		}    
	}
	class Member extends Customer {    
		void serveMember() {        
			System.out.println("會員服務");   
			}   
		@Override    
		public void accept(Visitor visitor) {        
			visitor.visit(this); // 看似多型，其實是 overload   
			}   
	}    
	
	class VisitorImpl implements Visitor {   
		public void visit(Member member) {        
			member.serveMember();    
		}    
		
	}
	class Slot {    
		private Visitor visitor = new VisitorImpl();    
		void Slot(Customer customer) {        
			customer.serveCustomer();        
			((Visitable) customer).accept(visitor);        
			customer.charge();    
			}
	}

	public class Main {    
		public void main(String[] args) {       
			Slot slot = new Slot();        
			slot.Slot(new Member());  
		     }
		}
	public static void main(String[] args) {
		

		
		
		try {
			for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
				if ("Nimbus".equals(info.getName())) {
					javax.swing.UIManager.setLookAndFeel(info.getClassName());
					break;
				}
			}
		} catch (ClassNotFoundException ex) {
			java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
		} catch (InstantiationException ex) {
			java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
		} catch (IllegalAccessException ex) {
			java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
		} catch (javax.swing.UnsupportedLookAndFeelException ex) {
			java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
		}

		java.awt.EventQueue.invokeLater(new Runnable() {

			public void run() {
			
				new GUI();
			}
		});		

	}
}


